home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000125_icon-group-sender _Sat May 10 20:35:43 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Mon, 12 May 1997 08:24:04 MST
  2. Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
  3.     id AA02983; Mon, 12 May 1997 08:24:04 -0700
  4. To: icon-group@cs.arizona.edu
  5. Date: Sat, 10 May 1997 20:35:43 +1000
  6. From: Stuart.Robinson@anu.edu.au (Stuart Robinson)
  7. Message-Id: <Stuart.Robinson-1005972035440001@asianstmg-212.anu.edu.au>
  8. Organization: ANU
  9. Sender: icon-group-request@cs.arizona.edu
  10. Subject: Problem with Program
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12. Status: RO
  13. Content-Length: 1528
  14.  
  15. Could someone tell me why the program below isn't working?  It's late and
  16. I must be overlooking something.  Given input like the following
  17.  
  18. This is a sample line 1{S {S
  19. This is a sample line 2{A {A
  20. This is a sample line 3{O {O
  21.  
  22. it should be produce the following output
  23.  
  24. S: 2
  25. A: 2
  26. O: 2
  27.  
  28. Thanks in advance.
  29.  
  30. ----------------
  31.  
  32. procedure main()
  33.  
  34. chars := &letters ++ &digits ++ '{.*[]?'     #valid characters
  35. noS := 0
  36. noA := 0
  37. noO := 0
  38.  
  39. while line := read() do                   #read in line
  40.    {
  41.    line ?                              #textscan line
  42.       {
  43.       while tab(upto(chars)) do           #look for valid character
  44.          {
  45.          word := tab(many(chars))         #word = valid character through
  46. next invalid character
  47.          word ?                        #textscan word
  48.             {
  49.             while tab(upto("{") +1) do    #move just past bracket (will
  50. fail if there is none)
  51.                {
  52.                wordfrag := move(1)        #wordfrag = one character past bracket
  53.                
  54.                case wordfrag of        #if wordfrag is
  55.                   {
  56.                   "S"   :  noS +:= 1      #S, then increment noS by 1
  57.                   "A"   :  noA +:= 1      #A, then increment noA by 1
  58.                   "O"   :  noO +:= 1      #O, then increment noO by 1
  59.                   }
  60.                }
  61.             }
  62.          }
  63.       }
  64.    }
  65.  
  66. write( "S: " || noS || \n || "A: " || noA || \n || "O: " || noO )
  67.  
  68. end
  69.  
  70. -- 
  71. Stuart Robinson <Stuart.Robinson@anu.edu.au>
  72. The Australian National University
  73.